#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include "string.h" 
#include "ClientSocket.h"

using namespace std;

//Constructor
ClientSocket::ClientSocket()
{
	m_Socket = SOCKET_ERROR;
	ZeroMemory(m_szBuffer, MAX_BUFFER_LEN);
	m_nTotalBytes = 0;
	m_nSentBytes = 0;
	m_pNext = NULL;
}

//destructor
ClientSocket::~ClientSocket()
{
	closesocket(m_Socket);
}

void ClientSocket::SetTotalBytes(int n)
{
	m_nTotalBytes = n;
}

int ClientSocket::GetTotalBytes()
{
	return m_nTotalBytes;
}

void ClientSocket::SetSentBytes(int n)
{
	m_nSentBytes = n;
}

void ClientSocket::IncrSentBytes(int n)
{
	m_nSentBytes += n;
}

int ClientSocket::GetSentBytes()
{
	return m_nSentBytes;
}

void ClientSocket::SetSocket(SOCKET s)
{
	m_Socket = s;
}

SOCKET ClientSocket::GetSocket()
{
	return m_Socket;
}

void ClientSocket::SetBuffer(const char *szBuffer)
{
	strcpy(m_szBuffer, szBuffer);
	SetTotalBytes(strlen(szBuffer));
}

void ClientSocket::GetBuffer(char *szBuffer)
{
	strcpy(szBuffer, m_szBuffer);
}

char* ClientSocket::GetBuffer()
{
	return m_szBuffer;
}

void ClientSocket::ZeroBuffer()
{
	ZeroMemory(m_szBuffer, MAX_BUFFER_LEN);
}

ClientSocket* ClientSocket::GetNext()
{
	return m_pNext;
}

void ClientSocket::SetNext(ClientSocket *pNext)
{
	m_pNext = pNext;
}

void ClientSocket::CloseSocket()
{
	//Close open sockets
	closesocket(m_Socket);

	//Cleanup Winsock
	//WSACleanup();
}
